<!doctype html>
<html>
<head>
	<title>Chart: Adding/Deleting Data Items</title>
	<script src="../../../codebase/webix.js" type="text/javascript"></script>
	<link rel="STYLESHEET" type="text/css" href="../../../codebase/webix.css">
	<script src="../../common/chartdata.js"></script>
<body>
    <div id="chartDiv" style="width:900px;height:200px;margin:20px"></div>
    <div style="margin:20px">
        <input type="button" value="add" onclick="addNew()">
	    <input type="button" value="delete" onclick="deleteFirst()">
    </div>
	<script>
        webix.ui({
            id:"barChart",
            container:"chartDiv",
            view:"chart",
            type:"bar",
            value:"#sales#",
            label:"#sales#",
            radius:0,
            gradient:"rising",
            barWidth:40,
            tooltip:{
                template:"#sales#"
            },
            xAxis:{
                title:"Sales per year",
                template:"'#year#",
                lines: false
            },
            padding:{
                left:10,
                right:10,
                top:50
            },
            data: dataset
        });
        var counter = 12;
        function addNew () {
            $$("barChart").add({
                year:"'"+counter,
                sales:(Math.random()*100).toFixed(0)
            });
            counter++;
        }
        function deleteFirst(){
            $$("barChart").remove($$("barChart").getFirstId());
        }
	</script>
</body>
</html>

	